﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Data;
using Common.GeneralClass;
using TCPIPControl.StructHelper;
using TcpLabCommon;
using System.Diagnostics;

namespace Common
{
     public  class MyDb : IDisposable
    {
        /// <summary></summary>
        private enum SqlType : int
        {
            /// <summary>Access</summary>
            Access = 0,

            /// <summary>SQL Server</summary>
            SqlServer
        }

        #region 

        /// <summary</summary>
        private SqlType _type;

        /// <summary></summary>
        private SqlConnection _connection = null;

        /// <summary></summary>
        private SqlCommand _command = null;

        /// <summary></summary>
        private SqlDataReader _reader = null;

        /// <summary></summary>
        private List<SqlParameter> _params = new List<SqlParameter>();

        public string dbconnectionstring = "";

        OperationText optxt = new OperationText();
        #endregion

        #region 

        /// <summary></summary>
        public SqlDataReader DataReader
        {
            get { return _reader; }
        }

        #endregion

        #region 

        /// <summary></summary>
        public MyDb(string conn)
        {
            dbconnectionstring = conn;
        }

        #endregion

        #region 

        /// <summary></summary>
        public void Dispose()
        {
            Close();
        }

        /// <summary></summary>
        /// <returns></returns>
        public bool Open()
        {
            //SystemINI sysini = SystemINI.ReadINIFile();
            //Cls_SystemSet ss = new Cls_SystemSet();

            //string dbconnectionstring = Mdl_Class.Systemset.DBConnectionString();

            return Open(dbconnectionstring);
        }

        /// <summary>打开连接</summary>
        /// <param _name="connectionString"></param>
        /// <returns></returns>
        public bool Open(string connectionString)
        {
            //
            _type = (connectionString.Contains(".mdb")) ? SqlType.Access : SqlType.SqlServer;

            if (_reader != null)
                _reader.Dispose();

            if (_command != null)
                _command.Dispose();

            if (_connection != null)
                _connection.Dispose();

            _params.Clear();

            switch (_type)
            {
                //case DbType.Access:
                //    _connection = new OleDbConnection();
                //    _command = new OleDbCommand();
                //    break;

                case SqlType.SqlServer:
                    _connection = new SqlConnection();
                    _command = new SqlCommand();
                    break;
            }

          
            if (_connection.State == System.Data.ConnectionState.Open)
                return true;

            try
            {
                _connection.ConnectionString = connectionString;
                _connection.Open();
                _command.Connection = _connection;
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库连接失败！", "提示");
                Mdl_Class.WriteLog.dbErrLog("数据库连接失败!", ex.ToString());
                return false;
            }

            return true;
        }

        /// <summary>关闭连接</summary>
        public void Close()
        {
            if (_reader != null)
                _reader.Dispose();

            if(_command!=null)
            _command.Dispose();

            if (_connection != null)
            _connection.Dispose();
            return;
        }

        /// <summary>SELECT查询</summary>
        /// <param name="sql">SQL</param>
        /// <returns>true或者false</returns>
        public bool ExecuteReader(string sql)
        {
            try
            {
                if (_reader != null)
                    _reader.Dispose();

                _command.Parameters.Clear();
                if (_params != null && _params.Count != 0)
                    _command.Parameters.AddRange(_params.ToArray());

                _command.CommandText = sql;

                _reader = _command.ExecuteReader();
            }
            catch (Exception)
            {

                return false;
            }

            return true;
        }

        /// <summary>SELECT查询</summary>
        /// <param name="sql">SQL</param>
        /// <returns>返回一个datatable</returns>
        public DataTable DataTableExecuteReader(string sql)
        {
            DataTable dt = null;
            try
            {
                if (_reader != null)
                    _reader.Dispose();

                _command.Parameters.Clear();
                if (_params != null && _params.Count != 0)
                    _command.Parameters.AddRange(_params.ToArray());

                _command.CommandText = sql;
                DataSet ds = new DataSet();
                SqlDataAdapter sda = new SqlDataAdapter(_command);
                sda.Fill(ds);
                dt = ds.Tables[0];
                //return dt;
                //_reader = _command.ExecuteReader();
                //_
            }
            catch (Exception)
            {

                return null;
            }

            return dt;
        }

        /// <summary>INSERT丄UPDATE丄DELETE语句</summary>
        /// <param name="sql">sql</param>
        /// <returns>int</returns>
        public int ExecuteNonQuery(string sql)
        {
            int result;

            try
            {
                _command.CommandText = sql;

                _command.Parameters.Clear();
                if (_params != null && _params.Count != 0)
                    _command.Parameters.AddRange(_params.ToArray());

                result = _command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = -1;
            }

            return result;
        }

        public string ExecuteScalar(string sql)
        {
            string result;

            try
            {
                _command.CommandText = sql;

                _command.Parameters.Clear();
                if (_params != null && _params.Count != 0)
                    _command.Parameters.AddRange(_params.ToArray());

                result = Convert.ToString(_command.ExecuteScalar());
            }
            catch (Exception)
            {
                result = "-1";
            }

            return result;
        }


            
        public string ExecuteScalar(string sql,byte[] by1)
        {
            string result;

            try
            {
                _command.CommandText = sql;

                _command.Parameters.Clear();
                _command.Parameters.Add("@abc", SqlDbType.Image).Value = by1;

                if (_params != null && _params.Count != 0)
                    _command.Parameters.AddRange(_params.ToArray());

                result = Convert.ToString(_command.ExecuteScalar());
            }
            catch (Exception)
            {
                result = "-1";
            }

            return result;
        }
        public int ExecuteNonQuery1(string sql,byte[] by1)
        {
            int result;

            try
            {
                //_command.CommandText = string.Format("insert into T_B_Test(UnitID,InsertTime,ChannelData) values('{0}','{1}',@abc)",1,DateTime.Now);

                _command.Parameters.Clear();
                _command.Parameters.Add("@abc", SqlDbType.Image).Value = by1;
                _command.CommandText = sql;
                //if (_params != null && _params.Count != 0)
                //    _command.Parameters.AddRange(_params.ToArray());

                result = _command.ExecuteNonQuery();
                //_command.CommandText = string.Format("insert into T_B_Test2(UnitID,InsertTime,ChannelData) values('{0}','{1}',@abc)", 1, DateTime.Now);

                //result = _command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = -1;
            }

            return result;
        }
         /// <summary>
         /// 插入
         /// </summary>
         /// <param name="tableName"></param>
         /// <param name="by1"></param>
         /// <param name="acq"></param>
         /// <returns></returns>
        public int ExecuteNonQuery_acq(string tableName,byte[] by1,ACQDB acq)
        {
            int result;

            try
            {
                //_command.CommandText = string.Format("insert into T_B_Test(UnitID,InsertTime,ChannelData) values('{0}','{1}',@abc)",1,DateTime.Now);

                _command.Parameters.Clear();

                _command.Parameters.Add("@abc", SqlDbType.Image).Value = by1;
                //if (tableName =="T_B_ACQ_Hour")
                //{
                    _command.CommandText = string.Format("insert into {0}(acqId,acqName,dataPaket,insertTime,projectId) values('{1}','{2}',@abc,'{3}',{4})", tableName, acq.acqId, acq.acqName, acq.insertTime.ToString("yyyy-MM-dd HH:mm:ss"),acq.projectId);
                    //_command.CommandText = string.Format("insert into {0}(Id,acqId,acqName,dataPaket,insertTime,projectId) values({1},'{2}','{3}',@abc,'{4}',{5})", tableName, acq.Id, acq.acqId, acq.acqName, acq.insertTime, acq.projectId);
                //}
                //else 
                //{
                //    _command.CommandText = string.Format("insert into {0}(Id,acqId,acqName,dataPaket,insertTime,projectId) values({1},'{2}','{3}',@abc,'{4}',{5})", tableName, acq.Id, acq.acqId, acq.acqName, acq.insertTime, acq.projectId);
                //}
                result = _command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = -1;
            }

            return result;
        }


        /// <summary>
        /// 插入振动加速度数据
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="by1"></param>
        /// <param name="acq"></param>
        /// <returns></returns>
        public int ExecuteNonQuery_acceleration(string tableName, byte[] by1, AccelerationDB acceler)
        {
            int result;

            try
            {
              
                _command.Parameters.Clear();

                _command.Parameters.Add("@abc", SqlDbType.Image).Value = by1;

                _command.CommandText = string.Format("insert into {0}(acqId,acqName,channelId,dataPaket,insertTime,projectId) values('{1}','{2}',{3},@abc,'{4}',{5})", tableName, acceler.acqId, acceler.acqName,acceler.channelId, acceler.insertTime.ToString("yyyy-MM-dd HH:mm:ss"), acceler.projectId);
             
                result = _command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = -1;
            }

            return result;
        }
        /// <summary>
        /// 插入并且返回插入自增ID
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="by1"></param>
        /// <param name="acq"></param>
        /// <returns></returns>
        public string ExecuteNonQuery_acq_return_ID(string tableName, byte[] by1, ACQDB acq)
        {
            string result = "";

            try
            {
                
                string sql = string.Format("insert into {0}(acqId,acqName,dataPaket,insertTime,projectId) values('{1}','{2}',@abc,'{3}',{4}) Select @@Identity", tableName, acq.acqId, acq.acqName, acq.insertTime, acq.projectId);
                result = ExecuteScalar(sql, by1);
            }
            catch (Exception)
            {
                result = "";
            }

            return result;
        }

         /// <summary>
         /// 批量插入
         /// </summary>
         /// <param name="tableName"></param>
         /// <param name="by1"></param>
         /// <param name="acq"></param>
         /// <returns></returns>
        public int ExecuteNonQuery_acq_batch(string tableName, List<byte[]> by1,List<ACQDB> acq,int add_count)
        {
            int result;

            try
            {
                //_command.CommandText = string.Format("insert into T_B_Test(UnitID,InsertTime,ChannelData) values('{0}','{1}',@abc)",1,DateTime.Now);

                _command.Parameters.Clear();
                for (int i = 0; i < add_count; i++)
                {
                    _command.Parameters.Add("@abc"+i, SqlDbType.Image).Value = by1[i];
                }
          
                //_command.CommandText = string.Format("insert into {0}(acqId,acqName,dataPaket,insertTime,projectId) values('{1}','{2}',@abc,GetDate(),{3})",tableName, acq.acqId, acq.acqName,acq.projectId);


                for (int i = 0; i < acq.Count; i++)
                {
                    if (i == 0)
                    {
                        _command.CommandText = string.Format("insert into {0}(acqId,acqName,dataPaket,insertTime,projectId) values('{1}','{2}',@abc{3},'{4}',{5})", tableName, acq[i].acqId, acq[i].acqName, i,acq[i].insertTime, acq[i].projectId);
                    }
                    else 
                    {
                       
                        _command.CommandText = _command.CommandText + string.Format(",('{0}','{1}',@abc{2},'{3}',{4})", acq[i].acqId, acq[i].acqName, i, acq[i].insertTime, acq[i].projectId);
                        
                    }
                }
                result = _command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = -1;
            }

            return result;
        }

        public string ExecuteNonQuery_BlackBox(string tableName, byte[] by1, BlackBoxDB bbdb)
        {
            string result;

            try
            {
          
                string sql = string.Format("insert into {0}(acqId,acqName,dataPaket,insertTime,projectId) values('{1}','{2}',@abc,GetDate(),{3}) Select @@Identity", tableName, bbdb.acqId, bbdb.acqName, bbdb.projectId);

               result = ExecuteScalar(sql, by1);
            }
            catch (Exception)
            {
                result = "-1";
            }

            return result;
        }


        public int ExecuteNonQuery_acq_task(string tableName, byte[] by1, ACQDB acq)
        {
            int result;

            try
            {
                //_command.CommandText = string.Format("insert into T_B_Test(UnitID,InsertTime,ChannelData) values('{0}','{1}',@abc)",1,DateTime.Now);

                _command.Parameters.Clear();

                _command.Parameters.Add("@abc", SqlDbType.Image).Value = by1;
                _command.CommandText = string.Format("insert into {0}(acqId,acqName,dataPaket,insertTime,projectId,taskId) values('{1}','{2}',@abc,GetDate(),{3},{4})", tableName, acq.acqId, acq.acqName, acq.projectId, acq.taskId);

                result = _command.ExecuteNonQuery();
            }
            catch (Exception)
            {
                result = -1;
            }

            return result;
        }



        /// <summary>
        /// 插入振动加速度数据
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public int ExecuteNonQuery_AccData( long rpmid ,string tableName, DateTime nowdate, AccData acceler)
        {
            int result;

            try
            {

                _command.Parameters.Clear();
                string values = "";
              
                string path = string.Format("{0}",nowdate.ToString("yyyyMMddHHmmss"));
                for (int i = 0; i < acceler.CHAccData.Length; i++)
                {
                    if (acceler.CHAccData[i].ChID>0) {
                        byte[] _1_3otcaveDB_bytes = FloatToBytes(acceler.CHAccData[i]._1_3otcaveDB);
                        byte[] FFTAmpDB_bytes = FloatToBytes(acceler.CHAccData[i].FFTAmpDB);
                        _command.Parameters.Add("@_1_3octavedBs" + i.ToString(), SqlDbType.Image).Value = _1_3otcaveDB_bytes;
                        _command.Parameters.Add("@FFTAmpDBs" + i.ToString(), SqlDbType.Image).Value = FFTAmpDB_bytes;
                        values = values + string.Format("('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',@_1_3octavedBs{15},@FFTAmpDBs{16})",
                        acceler.CHAccData[i].ChID,
                        acceler.CHAccData[i].TotalDB, acceler.CHAccData[i].highDB, acceler.CHAccData[i].lowDB, acceler.CHAccData[i].velocityRMS,
                        acceler.CHAccData[i].AverageVol, acceler.CHAccData[i].displacementRMS, acceler.CHAccData[i].OneMultiplierAmp, acceler.CHAccData[i].TWOMultiplierAmp,
                        acceler.CHAccData[i].HalfMultiplierAmp, acceler.CHAccData[i].AlarmFlag, nowdate, Mdl_Class.projectId, rpmid, path, i, i);
                        values = values + ",";
                    }
                }
                if (values.Length > 0)
                {
                    values = values.Substring(0, values.Length - 1);

                    _command.CommandText = string.Format("insert into {0}(ChannelId," +           
                        "TotaldB," +
                        "HighdB," +
                        "LowdB," +
                        "VelocityRMS," +
                        "AverageVol," +
                        "DisplacementRMS," +
                        "OneMultiplierAmp," +
                        "TwoMultiplierAmp," +
                        "HalfMultiplierAmp," +
                        "AlarmFlag," +
                        "InsertTime," +
                        "ProjectId," +
                        "RpmId,DatapaketPath,_1_3octavedB,FFTAmpDB) values " + values, tableName);


                    Stopwatch sp = new Stopwatch();
                    sp.Start();
                    result = _command.ExecuteNonQuery();


                    sp.Stop();
                    Console.WriteLine(sp.ElapsedMilliseconds);
                }
                else 
                {
                    result = -1;
                }
            }
            catch (Exception ex)
            {
                Mdl_Class.WriteLog.dbErrLog("ExecuteNonQuery_AccData()", ex.ToString());
                result = -1;
            }

            return result;
        }



       


        /// <summary>
        /// 插入振动加速度数据包txt
        /// </summary>
    
        public int ExecuteNonQuery_AccData_DataPaket(DateTime nowdate, AccData acceler)
        {
            int result;

            try
            {
                ChannelAccData_DataPaket datapaket = new ChannelAccData_DataPaket();
                datapaket.RawDatas = new ChannelAccData_RawData[32];
                //datapaket.FFTAmpDBs = new ChannelAccData_FFTAmpDB[32];
                //datapaket.FFTAmps = new ChannelAccData_FFTAmp[32];
                //datapaket.FFTPowers = new ChannelAccData_FFTPower[32];
                //datapaket.ElocityFFTAmps = new ChannelAccData_ElocityFFTAmp[32];
    
                for (int i = 0; i < acceler.CHAccData.Length; i++)
                {

               

                    datapaket.RawDatas[i] = new ChannelAccData_RawData();
                    //datapaket.FFTAmpDBs[i] = new ChannelAccData_FFTAmpDB();
                    //datapaket.FFTAmps[i] = new ChannelAccData_FFTAmp();
                    //datapaket.FFTPowers[i] = new ChannelAccData_FFTPower();
                    //datapaket.ElocityFFTAmps[i] = new ChannelAccData_ElocityFFTAmp();
     
                    datapaket.RawDatas[i].RawData = acceler.CHAccData[i].RawData;
                    //datapaket.FFTAmpDBs[i].FFTAmpDB = acceler.CHAccData[i].FFTAmpDB;
                    //datapaket.FFTAmps[i].FFTAmp = acceler.CHAccData[i].FFTAmp;
                    //datapaket.FFTPowers[i].FFTPower = acceler.CHAccData[i].FFTPower;
                    //datapaket.ElocityFFTAmps[i].ElocityFFTAmp = acceler.CHAccData[i].ElocityFFTAmp;
               


                }
                byte[] DataPaket_bytes = Activator.CreateInstance<StructHelper>().Serialize(datapaket);

                Stopwatch sp = new Stopwatch();
                sp.Start();
                //result = _command.ExecuteNonQuery();

                string str = Convert.ToBase64String(DataPaket_bytes);

                string path1 = string.Format(Application.StartupPath + "\\" + "{0}\\{1}.txt", "加速度数据", nowdate.ToString("yyyyMMddHHmmss"));
                optxt.WriteTXT("加速度数据", nowdate.ToString("yyyyMMddHHmmss"), str);

                //string readtxt = optxt.ReadTXT(path1);
                //byte[] decBytes = Convert.FromBase64String(readtxt);
                //ChannelAccData_DataPaket datapaket_new = Activator.CreateInstance<StructHelper>().DeSerialize<ChannelAccData_DataPaket>(decBytes);
                result = 1;
                sp.Stop();
                Console.WriteLine(sp.ElapsedMilliseconds);

            }
            catch (Exception ex)
            {
                Mdl_Class.WriteLog.dbErrLog("ExecuteNonQuery_AccData_DataPaket()", ex.ToString());
                result = -1;
            }

            return result;
        }


        /// <summary>
        /// 插入振动加速度数据
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public int ExecuteNonQuery_DisplacementData(long rpmid,string tableName, DateTime nowdate, DisplacementData displacementData)
        {
            int result;

            try
            {

                _command.Parameters.Clear();
                string values = "";
              
                for (int i = 0; i < displacementData.CHDisData.Length; i++)
                {
                    if (displacementData.CHDisData[i].ChID>0) {
                        byte[] Amps_bytes = FloatToBytes(displacementData.CHDisData[i].Amps);
                        byte[] Phs_bytes = FloatToBytes(displacementData.CHDisData[i].Phs);
                        byte[] ZDs_bytes = FloatToBytes(displacementData.CHDisData[i].ZDs);
                        _command.Parameters.Add("@Ampss" + i.ToString(), SqlDbType.Image).Value = Amps_bytes;
                        _command.Parameters.Add("@Phss" + i.ToString(), SqlDbType.Image).Value = Phs_bytes;
                        _command.Parameters.Add("@ZDss" + i.ToString(), SqlDbType.Image).Value = ZDs_bytes;
                        values = values + string.Format("('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',@Ampss{16},@Phss{17},@ZDss{18},'{19}')",
                       displacementData.CHDisData[i].ChID,
                       displacementData.CHDisData[i].PK2PK,
                       displacementData.CHDisData[i].RoomSquareValue,
                       displacementData.CHDisData[i].OneMultiplierAmp,
                       displacementData.CHDisData[i].OneMultiplierPhase,
                       displacementData.CHDisData[i].TWOMultiplierAmp,
                       displacementData.CHDisData[i].TWOMultiplierPhase,
                       displacementData.CHDisData[i].HalfMultiplierAmp,
                       displacementData.CHDisData[i].HaltMultiplierPhase,
                       displacementData.CHDisData[i].FreOption1,
                       displacementData.CHDisData[i].FreOption2,
                       displacementData.CHDisData[i].FreOption3,
                       displacementData.CHDisData[i].AlarmFlag,
                       nowdate,
                       Mdl_Class.projectId,
                       rpmid,
                       i,
                       i,
                       i,
                       displacementData.CHDisData[i].GapVoltage);
                        values = values + ",";
                    }
                }
                if (values.Length > 0)
                {
                    values = values.Substring(0, values.Length - 1);

                    _command.CommandText = string.Format("insert into {0}(ChannelId," +
                        "PK2PK," +
                        "RoomMeanSquareValue," +
                        "OneMultiplierAmp," +
                        "OneMultiplierPhase," +
                        "TWOMultiplierAmp," +
                        "TWOMultiplierPhase," +
                        "HalfMultiplierAmp," +
                        "HalfMultiplierPhase," +
                        "FreOption1," +
                        "FreOption2," +
                        "FreOption3," +
                        "AlarmFlag," +
                        "InsertTime," +
                        "ProjectId," +
                        "RpmId,Amps,Phs,ZDs,GapVoltage) values " + values, tableName);


                    Stopwatch sp = new Stopwatch();
                    sp.Start();
                    result = _command.ExecuteNonQuery();


                    sp.Stop();
                    Console.WriteLine(sp.ElapsedMilliseconds);
                }
                else
                {
                    result = -1;
                }
            }
            catch (Exception ex)
            {
                Mdl_Class.WriteLog.dbErrLog("ExecuteNonQuery_DisplacementData()", ex.ToString());
                result = -1;
            }

            return result;
        }


        /// <summary>开始事务</summary>
        /// <remarks>
        /// </remarks>
        public void BeginTransaction()
        {
            _command.Transaction = _connection.BeginTransaction();
          
        }

      

        /// <summary>提交事务</summary>
        public void Commit()
        {
            _command.Transaction.Commit();
        }



        /// <summary>回滚事务</summary>
        public void Rollback()
        {
            _command.Transaction.Rollback();
        }

        /// <summary>清除</summary>
        public void ClearParam()
        {
            _params.Clear();
        }

        /// <summary>sql或者access</summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <remarks>

        /// </remarks>
        public void AddParam(string key, object value)
        {
            SqlParameter param = null;

            switch (_type)
            {
                //case DbType.Access:
                //    param = new OleDbParameter(key, value);
                //    break;

                case SqlType.SqlServer:
                    param = new SqlParameter(key, value);
                    break;
            }

            _params.Add(param);
        }


        public byte[] Int32ToBytes(Int32[] ints) 
        {
            byte[] results = new byte[ints.Length * sizeof(int)];
            Buffer.BlockCopy(ints, 0, results, 0, results.Length);
            return results;
        }

        public byte[] FloatToBytes(float[] floats)
        {
            byte[] results = new byte[floats.Length * sizeof(float)];
            Buffer.BlockCopy(floats, 0, results, 0, results.Length);
            return results;
        }

        public Int32[] BytesToInt32(byte[] bytes) 
        {
            Int32[] ints = new int[bytes.Length / sizeof(int)];
            Buffer.BlockCopy(bytes, 0, ints, 0, bytes.Length);
            return ints;
        }

        public float[] BytesToFloat(byte[] bytes)
        {
            float[] floats = new float[bytes.Length / sizeof(float)];
            Buffer.BlockCopy(bytes, 0, floats, 0, bytes.Length);
            return floats;
        }

        public string Int32ToString(Int32[] objs) 
        {
            string stringvalues = "";
            for (int i=0; i< objs.Length;i++)
            {
                if (i == 0)
                {
                    stringvalues = objs[i].ToString();
                }
                else 
                {
                    stringvalues = stringvalues+ "," + objs[i].ToString();
                }
            }
            return stringvalues;
        }


        public string FloatToString(float[] objs)
        {
            string stringvalues = "";
            for (int i = 0; i < objs.Length; i++)
            {
                if (i == 0)
                {
                    stringvalues = objs[i].ToString();
                }
                else
                {
                    stringvalues = stringvalues + "," + objs[i].ToString();
                }
            }
            return stringvalues;
        }

        #endregion
    }
}
